<?php
$name = "张三 hello"; // utf-8 对应一个中文3个字节

//echo "hello $name";
// 双引号可以解析变量, 单引号中的字符串如果有变量，不解析。
//echo 'hello $name';

//echo 'I\'m \\ zhangsan';

// 求字符串的长度

//$len = strlen($name);
//$len = mb_strlen($name);
//echo $len;

//trim()、rtrim()、ltrim()
//
//$str = ',Hello,';
////echo mb_strlen($str);
//$str2 = rtrim($str, ',');
//echo $str2;

// md5() 用于加密，生成加密数据时32位，不可逆的

$password = '123455';

$md5_pwd = md5($password);

//echo $md5_pwd;

//$username = 'XXXX'; // select * from users where username = $username;
//if () echo '用户名不存在';
//$password = '123456';
//if (md5($password) != 数据库密码) echo '密码不正确';

// str_replace
//
//$card_no = '132155198907131127';
//
//
////echo $card_no[0] . '******' . $card_no[-1];
//$cut_str = mb_strcut($card_no, 6, 8);
////echo $cut_str;
//$new_str = str_replace($cut_str, '*******', $card_no);
//
//echo $new_str;


$hobby = ['篮球', '足球', '排球'];

$str_hobby = implode('-', $hobby);

echo $str_hobby;

$keywords = ['PHP', 'MySQL', 'Javascript'];

echo implode(',', $keywords);


$keywords = 'PHP,MySQL,Javascript';
$keywords = explode(',', $keywords);
print_r($keywords);
?>

<html>
<head>

    <style>
        .keywords span {
            background-color: gray;
            padding: 5px 10px;
        }
    </style>
</head>
<body>
    <div class="keywords">
        <?php foreach ($keywords as $val):?>
        <span><?php echo $val?></span>
        <?php endforeach;?>
    </div>
</body>
</html>


